#pragma once
#include "../core/Object.h"
#include "../core/Scene.h"
#include "../cameras/Camera.h"
#include "../core/materials/Material.h"
#include "../geometries/BufferGeometry.h"
POCELAIN_NAMESPACE_BEGIN

enum ERenderBufferType
{
    E_BUFFER_COLOR,
    E_BUFFER_DEPTH,
    E_BUFFER_STENCIL,
};

POCELAIN_EXPORT class IRenderer : public Object
{
public:
    IRenderer(){};
    virtual ~IRenderer() {};
    virtual void render(Scene *scene, Camera *camera) = 0;
    virtual void clearBuffer(ERenderBufferType bufferType) = 0;
    void clearAllBuffer()
    {
        clearBuffer(ERenderBufferType::E_BUFFER_COLOR);
        clearBuffer(ERenderBufferType::E_BUFFER_DEPTH);
        clearBuffer(ERenderBufferType::E_BUFFER_STENCIL);
    }
    void clearColor(){clearBuffer(ERenderBufferType::E_BUFFER_COLOR);}
    void clearDepth(){clearBuffer(ERenderBufferType::E_BUFFER_DEPTH);}
    void clearStencil(){clearBuffer(ERenderBufferType::E_BUFFER_STENCIL);}

protected:
    void clearMaterialDirty(Material *material)
    {
        material->mDirty = false;
    }
    void clearGeometryDirty(BufferGeometry *geometry)
    {
        geometry->mDirty = false;
    }
    void setRenderData(RenderDataCacheHelper *helper, IRenderData *data)
    {
        helper->setRenderData(data);
    }
    IRenderData *getRenderData(RenderDataCacheHelper *helper)const
    {
        return helper->getRenderData();
    }
};

POCELAIN_NAMESPACE_END
